<template>
  <button @click="handleClick">click</button>
</template>
<script setup>
import { defineEmits } from "vue";
const emit = defineEmits(["buttonClicked"]);
const handleClick = () => {
  //子组件触发自定义事件，事件名称为buttonClicked，参数为hello
  emit("buttonClicked", "hello");
};
</script>

<script>
/* export default {
  setup(props, { emit }) {
    const handleClick = () => {
      //子组件触发自定义事件，事件名称为buttonClicked，参数为hello
      emit("buttonClicked", "hello");
    };
    return {
      handleClick,
    };
  },
}; */
</script>
